import request from '@/utils/request'
import { AircraftType, BattleRoyaleType, LuckType, SweepType, TigerType } from '@/views/configManage/components/gameDataConversion'

// 游戏列表
export function getGame(params: any) {
  return request({
    url: '/v1/config/getGameList',
    method: 'get',
    params: params
  })
}

// 新增游戏
export function addGame(data: any) {
  return request<{ foo: string }>({
    url: '/v1/config/addGame',
    method: 'post',
    data: data
  })
}

// 编辑游戏
export function editGame(data: any) {
  return request({
    url: '/v1/config/updateGame',
    method: 'post',
    data: data
  })
}

// 关闭游戏
export function postChangeMaintain(data: any) {
  return request({
    url: '/v1/admin/configure/changeMaintain',
    method: 'post',
    data: data
  })
}

// 通过运营商获取【老虎机】配置
export async function getOperatorTiger(params: any) {
  return request({
    url: '/v1/config/getSlotGameConfig',
    method: 'get',
    params: params
  }).then((res) => {
    res.data = new TigerType().apiLocal(res.data)
    return res
  })
}

// 查看-老虎机游戏状态
export function getGameStatus(data: any) {
  return request({
    url: '/v1/config/getNowGameStatus',
    method: 'post',
    data: data
  })
}

// 编辑老虎机
export function editTiger(data: any,type:boolean) {
  if(type){
    data = new TigerType().localApi(data)
  }
  return request({
    url: '/v1/config/updateSlotGameConfig',
    method: 'post',
    data: data
  })
}

// 通过运营商获取【百人场】配置
export function getHundredConfig(params: any) {
  return request({
    url: '/v1/config/getHundredConfig',
    method: 'get',
    params: params
  }).then((res) => {
    // 飞机
    if(params.game_id == 100001){
      res.data = new AircraftType().apiLocal(res.data)
    }
    // 大逃杀
    if(params.game_id == 100002){
      res.data = new BattleRoyaleType().apiLocal(res.data)
    }
    // Luck49
    if(params.game_id == 100003){
      res.data = new LuckType().apiLocal(res.data)
    }
    return res
  })
}

// 编辑百人场
export function editHundredConfig(data: any) {
  // 飞机
  if(data.game_id == 100001){
    data = new AircraftType().localApi(data)
  }
  // 大逃杀
  if(data.game_id == 100002){
    data = new BattleRoyaleType().localApi(data)
  }
  // Luck49
  if(data.game_id == 100003){
    data = new LuckType().localApi(data)
  }
  return request({
    url: '/v1/config/updateHundredConfig',
    method: 'post',
    data: data
  })
}

// 获取当前期数详情
export function getPeriodDetails(params: any) {
  return request({
    url: '/v1/luckAction/getNowLuckData',
    method: 'get',
    params: params
  })
}
// 新增-是否有调控冲突
export function checkAction(data: any) {
  return request({
    url: '/v1/luckAction/getAffectedData',
    method: 'post',
    data: data
  })
}
// 新增-luck群控
export function addLuckAction(data: any) {
  return request({
    url: '/v1/luckAction/addLuckAction',
    method: 'post',
    data: data
  })
}
// 修改-luck群控
export function editLuckAction(data: any) {
  return request({
    url: '/v1/luckAction/updateLuckAction',
    method: 'put',
    data: data
  })
}
// 删除-luck群控
export function deleteLuckAction(data: any) {
  return request({
    url: '/v1/luckAction/deleteLuckAction',
    method: 'delete',
    data: data
  })
}
// luck群控操作记录
export function getLuckAction(params: any) {
  return request({
    url: '/v1/luckAction/getNowActionData',
    method: 'get',
    params: params
  })
}
// luck下注情况
export function getLuckBet(params: any) {
  return request({
    url: '/v1/luckAction/getUserLuckBetList',
    method: 'get',
    params: params
  })
}

// 通过运营商获取【街机】配置
export async function getOperatorSweep(params: any) {
  return request({
    url: '/v1/config/getMineConfig',
    method: 'get',
    params: params
  }).then((res) => {
    res.data = new SweepType().apiLocal(res.data)
    return res
  })
}

// 编辑街机
export function editSweep(data: any) {
  data = new SweepType().localApi(data)
  return request({
    url: '/v1/config/updateMineConfig',
    method: 'post',
    data: data
  })
}

// 获取水位配置
export function getPool(params: any) {
  return request({
    url: '/v1/admin/configure/waterLevelList',
    method: 'get',
    params: params
  })
}
// 修改水位配置
export function editPool(data: any) {
  return request({
    url: '/v1/admin/configure/changeWaterLevel',
    method: 'post',
    data: data
  })
}

// 游戏水位观测-折线图
export function getWaterChart (params: any) {
  return request({
    url: '/v1/admin/configure/waterWatchChart',
    method: 'get',
    params: params
  })
}
// 游戏水位观测-列表
export function getWaterTable(params: any) {
  return request({
    url: '/v1/admin/configure/waterWatchList',
    method: 'get',
    params: params
  })
}

// 全局表配置-列表
export function getGlobal(params: any) {
  return request({
    url: '/v1/config/globalList',
    method: 'get',
    params: params
  })
}
// 修改全局表配置
export function editGlobal(data: any) {
  return request({
    url: '/v1/config/updateGlobalList',
    method: 'post',
    data: data
  })
}

// 初始化全局表默认配置
export function initializeGlobal(data: any) {
  return request({
    url: '/v1/config/initializeGlobalConfig',
    method: 'post',
    data: data
  })
}

// 初始化Slot默认配置
export function initializeSlot(data: any) {
  return request({
    url: '/v1/config/initializeSlotPgGame',
    method: 'post',
    data: data
  })
}

// 初始化百人场默认配置
export function initializeHundred(data: any) {
  return request({
    url: '/v1/config/initializeHundred',
    method: 'post',
    data: data
  })
}

// 初始化游戏表
export function initializeGame(data: any) {
  return request({
    url: '/v1/config/initializeCGame',
    method: 'post',
    data: data
  })
}

// 可重载表名
export function getOverloadTable (params: any) {
  return request({
    url: '/v1/config/readConfig',
    method: 'get',
    params: params
  })
}
// 重载表
export function overloadTable (data: any) {
  return request({
    url: '/v1/config/loadConfig',
    method: 'post',
    data: data
  })
}

// 同步数据到商户-全局配置
export function coverGlobal(data: any) {
  return request({
    url: '/v1/config/coverGlobalConfig',
    method: 'post',
    data: data
  })
}
// 同步数据到商户-slot
export function coverSlot(data: any) {
  return request({
    url: '/v1/config/coverPgGameConfig',
    method: 'post',
    data: data
  })
}
// 同步数据到商户-百人场
export function coverHundred(data: any) {
  return request({
    url: '/v1/config/coverHundredConfig',
    method: 'post',
    data: data
  })
}
// 同步数据到商户-游戏表
export function coverGame(data: any) {
  return request({
    url: '/v1/config/coverCGame',
    method: 'post',
    data: data
  })
}

// 批量维护游戏
export function editMaintainGame(data: any) {
  return request({
    url: '/v1/config/updateMoreGameStatus',
    method: 'put',
    data: data
  })
}